package model.semantics.infinary;

import model.RGBColor;
import model.semantics.InfinaryOperation;

/**
 * Find the maximum based on intensity.
 * 
 * @author Anne Weng
 */
public class Max extends InfinaryOperation {

	@Override
    protected RGBColor evaluateColor (RGBColor[] colors)
    {
		double maximum = Double.MIN_VALUE;					//Initialize maximum
		RGBColor maxColor = null;
        for (int i = 0; i < colors.length; i++)
        {
        	RGBColor current = colors[i];
        	double sum = current.getRed() + current.getBlue() + current.getGreen();
        	if (sum > maximum) {
        		maximum = 0 + sum;
        		maxColor = colors[i];
        	}
        }
        return maxColor;
    }
	
}
